using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Array
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = new int[] { 2, 4, 6, 8 };
            int[] arr1 = { 1, 3, 5, 7, 9 };
            int[] arr2 = new int[5];
            int[,] arr3 = new int[2, 3] { { 11, 12, 13 }, { 21, 22, 23 } };
            int[,] arr4 = { { 411, 412, 413 }, { 421, 422, 423 } };
            int[, ,] arr5 = { { { 111, 112 }, { 121, 122 } }, { { 211, 212 }, { 221,222} }, { { 311, 312 }, {321,322 } } };
            int[][] arr6 = new int[3][];
            arr6[0] = new int[] {611,612,613};
            arr6[1] = new int[] {621,622,623,624};
            arr6[2] = new int[] {631, 632};
            string sTemp;
            
            ArrayList al = new ArrayList();

            for (int i = 0; i < 6; i++)
                al.Add(i + 2 * i);

            for (int i = 0; i < arr2.Length; i++)
                arr2[i] = (int)Math.Pow(i, 2) * i * 2;
            Console.WriteLine("====================");

            for (int i = 0; i < arr.Length; i++)
                Console.WriteLine("arr[{0}]={1}", i, arr[i]);
            Console.WriteLine("====================");

            foreach (int i in arr1)
                Console.WriteLine("{0}", i);
            Console.WriteLine("====================");

            for (int i = 0; i < arr2.Length; i++)
                Console.WriteLine("arr2[{0}]={1}", i, arr2[i]);
            Console.WriteLine("====================");

            for (int i = 0; i < arr3.Rank; i++)
                for (int j = 0; j < arr3.GetUpperBound(arr3.Rank - 1) + 1; j++)
                    Console.WriteLine("arr3[{0}][{1}]={2}", i, j, arr3[i, j]);
            Console.WriteLine("====================");

            for (int i = 0; i < arr4.Rank; i++)
                for (int j = 0; j < arr4.GetUpperBound(arr4.Rank - 1) + 1; j++)
                    Console.WriteLine("arr4[{0}][{1}]={2}", i, j, arr4[i, j]);
            Console.WriteLine("====================");

            for (int i = 0; i < arr5.Rank; i++)
                for (int j = 0; j < arr5.GetUpperBound(arr5.Rank - 1) + 1; j++)
                    for(int t =0; t<arr5.GetUpperBound(arr5.Rank -2) + 1; t++)
                        Console.WriteLine("arr5[{0}][{1}][{2}]={3}", i, j,t, arr5[i, j, t]);
            Console.WriteLine("====================");
            
            Console.WriteLine("Printing arr6 with method 1:");
            for(int i=0; i<arr6.Length; i++)
            {
            	for(int j=0; j<arr6[i].Length; j++)
            		Console.Write("[{0}][{1}]={2} ", i, j, arr6[i][j]);
            	Console.Write("\n");
            }
            
            Console.WriteLine("Printing arr6 with method 2:");
            foreach(int[] i in arr6)
            {
            	foreach(int j in i)
            		Console.Write("{0} ", j);
            	Console.Write("\n\n");
            }
            
            foreach (int i in al)
                Console.WriteLine(i);
            Console.WriteLine("====================");
            
            al.Clear();
            while(true){
            	Console.WriteLine("Please enter a string, [end] for exit:");
            	sTemp = Console.ReadLine();
            	if(sTemp == "end")	break;
            	al.Add(sTemp);
            	
            	foreach(string s in al)
            		Console.Write("{0} ", s);
            	Console.Write("\n");
            }
            
            Console.ReadLine();
        }
    }
}
